﻿#include "bank.h"

// 初始化队列
void initQueue(Queue* queue) {
    queue->front = NULL;
    queue->rear = NULL;
    queue->size = 0;
}

// 检查队列是否为空
Status isEmpty(Queue* queue) {
    return queue->size == 0;
}

// 向队列中加入客户
void enqueue(Queue* queue, Customer* customer) {
    if (queue->rear == NULL) {
        queue->front = customer;
        queue->rear = customer;
    }
    else {
        queue->rear->next = customer;
        queue->rear = customer;
    }
    customer->next = NULL;
    queue->size++;
}

// 从队列中移除客户
Customer* dequeue(Queue* queue) {
    if (isEmpty(queue)) {
        return NULL;
    }
    Customer* customer = queue->front;
    queue->front = customer->next;
    if (queue->front == NULL) {
        queue->rear = NULL;
    }
    queue->size--;
    return customer;
}

Customer* getFrontCustomer(Queue queue) {
    return queue.front;
}
